package com.gl.portal.system.repository;

import com.gl.portal.system.entity.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

public interface SysUserRepository extends JpaRepository<SysUser, Long>, JpaSpecificationExecutor<SysUser> {

	SysUser findByPhoneAndIsDeleted(String phone, Integer isDeleted);

	SysUser findByEmailAndIsDeleted(String email, Integer isDeleted);

	int countByLoginNameAndIsDeleted(String loginName, Integer isDeleted);

	List<SysUser> findByIdIn(List<Long> ids);

	/**
	 * 根据登录账号查询
	 *
	 * @param loginName 登录账号
	 * @return
	 */
	SysUser findByLoginName(String loginName);


	SysUser findByLoginNameAndPassword(String loginName,String password);

	/**
	 * 查询部门是否存在用户
	 *
	 * @param deptId
	 * @param isDeleted
	 * @return
	 */
	int countByDeptIdAndIsDeleted(Long deptId, Integer isDeleted);

	List<SysUser> findByLoginNameAndIsDeleted(String loginName,Integer isDeleted);
}
